import Vue from 'vue'
import Vuex from 'vuex'

import {
  eduClassesQuery,
  eduClassesDelete,
  eduClassesAdd,
  eduClassesUpdate,
} from '@/api/admin/courseLibrary/eduClasses.js'

Vue.use(Vuex)

const state = {}

const getters = {}

const actions = {
  async queryEduClasses({ commit }, listQuery) {
    let res = await eduClassesQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async deleteEduClasses({ commit }, row) {
    let res = await eduClassesDelete(row.id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async addEduClasses({ commit }, data) {
    let res = await eduClassesAdd(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async updateEduClasses({ commit }, data) {
    let res = await eduClassesUpdate(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
}

const mutations = {}

export default {
  state,
  getters,
  actions,
  mutations,
}
